﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Web;
using System.Net;
using androidpost.Utils;

namespace androidpost
{
    public partial class register : Form
    {
        WebClient cGet = new WebClient();
        public register()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String b = String.Format(Constant.domain + "register.php?id={0}&email={1}&name={2}", txtEmail.Text + txtMatkhau.Text, txtEmail.Text, txtHoTen.Text);
            if ((txtEmail.Text == "") || (txtMatkhau.Text == "")) MessageBox.Show("You must type enough information");
            else
            try
            {
                String a = cGet.DownloadString(b);
                
                if (a.IndexOf("219")!=-1)
                {
                    MessageBox.Show("Register success");
                    this.Close();
                }
                else MessageBox.Show("LỖI ĐĂNG KÝ!\n Email này đã được sử dụng");
            }
            catch (Exception)
            {

                MessageBox.Show("Lỗi truy cập mạng!");
            }
           
            
        }

        private void register_FormClosing(object sender, FormClosingEventArgs e)
        {
            login fomlog = new login();
            fomlog.Show();
            this.Hide();
        }

        private void register_Load(object sender, EventArgs e)
        {

        }
    }
}
